package dk.ucn.datamatiker.henrik.bundtkage.earthcake.albeheweather;

import java.io.IOException;

import org.xmlpull.v1.XmlPullParser;
import org.xmlpull.v1.XmlPullParserException;

public class Location {
	private String id;
	private String description;
	private String type;

	public Location(XmlPullParser parser) throws XmlPullParserException,
			IOException {
		readLocationData(parser);
	}

	public Location(String id, String description, String type) {
		super();
		this.id = id;
		this.description = description;
		this.type = type;
	}

	public void readLocationData(XmlPullParser parser)
			throws XmlPullParserException, IOException {
		parser.require(XmlPullParser.START_TAG, null, "Location");
		while (parser.next() != XmlPullParser.END_TAG) {
			if (parser.getEventType() != XmlPullParser.START_TAG) {
				continue;
			}
			String name = parser.getName();

			if (parser.next() == XmlPullParser.TEXT) {

				if (name.equals("Id")) {
					setId(parser.getText());
					parser.nextTag();
				} else if (name.equals("Description")) {
					setDescription(parser.getText());
					parser.nextTag();
				} else if (name.equals("Type")) {
					setType(parser.getText());
					parser.nextTag();
				} else {
					parser.nextTag();
				}
			}
		}
	}

	public String getId() {
		return id;
	}

	public void setId(String id) {
		this.id = id;
	}

	public String getDescription() {
		return description;
	}

	public void setDescription(String description) {
		this.description = description;
	}

	public String getType() {
		return type;
	}

	public void setType(String type) {
		this.type = type;
	}
}
